#!/bin/bash
echo -e "\n$(date)\nhost\tifname|driver|\033[31mcarrier_changes\033[0m ...";for x in $(cat /etc/hosts|awk '{print $1}'|grep -v -E "^#|:"|sort|uniq);do echo -n -e "$x\t"; ssh -o "BatchMode yes" -o ConnectTimeout=5 $x "sh -c \"for c in \\\$(ip a s|grep \\\"^[1-9][0-9]*:\\\" |awk '{print \\\$2}'|grep -v -E \\\"@|^lo|^qbr|^tap|^docker|^virbr|^br-|^fg-|^qg-|^qr-|^ovs-|^vxlan|^flannel|^cni|^vnet|^bond\\\" |tr -d \\\":\\\");do driver=\\\$(ethtool -i \\\$c |grep \\\"^driver\\\" |awk '{print \\\$2}');echo -n -e \\\"\\\$c|\\\$driver|\033[31m\\\$(cat /sys/class/net/\\\$c/carrier_changes)\033[0m\\\t\\\"; done\"";echo;done
